package com.ruoyi.web.area.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.web.utils.ManualPagination;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.area.domain.HrCt007;
import com.ruoyi.web.area.service.IHrCt007Service;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * areaController
 * 
 * @author ruoyi
 * @date 2024-09-26
 */
@RestController
@RequestMapping("/area/ct007")
public class HrCt007Controller extends BaseController
{
    @Autowired
    private IHrCt007Service hrCt007Service;

    /**
     * 查询area列表
     */
    @PreAuthorize("@ss.hasPermi('area:ct007:list')")
    @GetMapping("/list")
    public TableDataInfo list(HrCt007 hrCt007)
    {
//        startPage();
        List<HrCt007> list = hrCt007Service.selectHrCt007List(hrCt007);
        return ManualPagination.pagination(list);
    }

    /**
     * 导出area列表
     */
    @PreAuthorize("@ss.hasPermi('area:ct007:export')")
    @Log(title = "area", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HrCt007 hrCt007)
    {
        List<HrCt007> list = hrCt007Service.selectHrCt007List(hrCt007);
        ExcelUtil<HrCt007> util = new ExcelUtil<HrCt007>(HrCt007.class);
        util.exportExcel(response, list, "area数据");
    }

    /**
     * 获取area详细信息
     */
    @PreAuthorize("@ss.hasPermi('area:ct007:query')")
    @GetMapping(value = "/{ccodeID}")
    public AjaxResult getInfo(@PathVariable("ccodeID") String ccodeID)
    {
        return success(hrCt007Service.selectHrCt007ByCcodeID(ccodeID));
    }

    /**
     * 新增area
     */
    @PreAuthorize("@ss.hasPermi('area:ct007:add')")
    @Log(title = "area", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HrCt007 hrCt007)
    {
        return toAjax(hrCt007Service.insertHrCt007(hrCt007));
    }

    /**
     * 修改area
     */
    @PreAuthorize("@ss.hasPermi('area:ct007:edit')")
    @Log(title = "area", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HrCt007 hrCt007)
    {
        return toAjax(hrCt007Service.updateHrCt007(hrCt007));
    }

    /**
     * 删除area
     */
    @PreAuthorize("@ss.hasPermi('area:ct007:remove')")
    @Log(title = "area", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ccodeIDs}")
    public AjaxResult remove(@PathVariable String[] ccodeIDs)
    {
        return toAjax(hrCt007Service.deleteHrCt007ByCcodeIDs(ccodeIDs));
    }
}
